package com.atguigu.springcloud.alibaba.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.List;

@RestController
public class OrderZKController {


    public static final String INVOKE_URL = "http://MICROSERVICECLOUD-DEPT-PROVIDER";

    @Autowired
    private RestTemplate restTemplate;

    @RequestMapping(value = "/consumer/payment/zk")
    public String paymentInfo() {
        String result = restTemplate.getForObject(INVOKE_URL + "/payment/zk", String.class);
        System.out.println("消费者调用支付服务(zookeeper)--->result:" + result);
        return result;
    }

    @GetMapping(value = "/consumer/test1")
    public Object test1() {
        List list = restTemplate.getForObject(INVOKE_URL + "/dept/list", List.class);
        return list;
    }

    @RequestMapping(value = "/consumer/port")
    public String port() {
        String result = restTemplate.getForObject(INVOKE_URL + "/dept/serverPort", String.class);
        return result;
    }

}